﻿using AutoMapper;
using Blog.Core.Services.BASE;
using Core.Common;
using Core.DTO;
using IRepository;
using IServices;
using Repository;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace Services
{

   public class BlogArticleServices : BaseServices<BlogArticle>, IBlogArticleServices
    {
        IBlogArticleRepository dal;
        IMapper _IMapper;
        public BlogArticleServices(IBlogArticleRepository dal, IMapper IMapper)
        {
            this.dal = dal;
            base.baseDal = dal;
            _IMapper = IMapper;

        }
        [Caching(AbsoluteExpiration = 30)]
        public Task<List<BlogArticle>> Get()
        {
          return  dal.Query();
        }

        //IAdvertisementRepository dal = new AdvertisementRepository();

        public int Sum(int i, int j)
        {
            return dal.Sum(i, j);

        }



        public async Task<BlogViewModels> Getdetail(int id)
        {

          BlogArticle bl=await dal.QueryByID(id);
            BlogViewModels bs= _IMapper.Map<BlogViewModels>(bl);
            return bs;
        }



    }
}
